<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <title></title>
    <link rel="stylesheet" href="css/base.css"/>
    <link rel="stylesheet" href="css/index.css"/>
    <!--<script src="zepto-master/zepto/src/zepto.min.js"></script>
    <script src="zepto-master/zepto/src/selector.js"></script>
    <script src="zepto-master/zepto/src/fx.js"></script>
    <script src="zepto-master/zepto/src/touch.js"></script>-->
    <script src="js/zepto.min.js"></script>
</head>
<body>
<div class="jd_layout">
    <div class="jd_search">
        <a href="javascript:;" class="jd_logo"></a>
        <form action="" class="searchBox">
            <input type="text" placeholder="请输入商品名称"/>
        </form>
        <a href="javascript:;" class="jd_login">登录</a>
    </div>
    <div class="jd_banner">
        <ul class="banner_img">
            <li><a href="javascript:;"><img src="./uploads/l1.jpg" alt=""/></a></li>
            <li><a href="javascript:;"><img src="./uploads/l2.jpg" alt=""/></a></li>
            <li><a href="javascript:;"><img src="./uploads/l3.jpg" alt=""/></a></li>
            <li><a href="javascript:;"><img src="./uploads/l4.jpg" alt=""/></a></li>
            <li><a href="javascript:;"><img src="./uploads/l5.jpg" alt=""/></a></li>
            <li><a href="javascript:;"><img src="./uploads/l6.jpg" alt=""/></a></li>
            <li><a href="javascript:;"><img src="./uploads/l7.jpg" alt=""/></a></li>
            <li><a href="javascript:;"><img src="./uploads/l8.jpg" alt=""/></a></li>
        </ul>
        <ol class="banner_circle">
            <li class="active"></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ol>
    </div>
    <div class="jd_nav clearfix">
        <ul>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_1.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_2.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_3.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_4.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_5.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_6.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_7.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                    <img src="images/nav_8.png" alt=""/>
                    <p>商品分类</p>
                </a>
            </li>
        </ul>
    </div>
    <div class="jd_product">
        <div class="productBox jd_miaosha m_top10">
            <div class="jd_pTip">
                <div class="jd_left">
                    <span class="clock f_left"></span>
                    <span class="f_left m_left10 jd_left_text">元旦秒杀</span>
                    <div class="jd_time f_left m_left10">
                        <span class="f_left">0</span>
                        <span class="f_left">0</span>
                        <span class="f_left">:</span>
                        <span class="f_left">0</span>
                        <span class="f_left">0</span>
                        <span class="f_left">:</span>
                        <span class="f_left">0</span>
                        <span class="f_left">0</span>
                        <span class="f_left">:</span>
                        <span class="f_left">0</span>
                        <span class="f_left">0</span>
                    </div>
                </div>
                <div class="jd_right f_right m_right10">过节...</div>
            </div>
            <div class="jd_pContent clearfix jd_shirt">
                <ul>
                    <li>
                        <a href="javascript:;" class="f_left">
                            <img src="uploads/detail01.jpg" alt=""/>
                            <p>&yen;10.00</p>
                            <p>&yen;20.00</p>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:;" class="f_left">
                            <img src="uploads/detail01.jpg" alt=""/>
                            <p>&yen;10.00</p>
                            <p>&yen;20.00</p>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:;" class="f_left">
                            <img src="uploads/detail01.jpg" alt=""/>
                            <p>&yen;10.00</p>
                            <p>&yen;20.00</p>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="productBox m_top10">
            <div class="jd_pTip border_b">
                <h3>京东超市</h3>
            </div>
            <div class="jd_pContent clearfix">
                <a href="javascript:;"><img src="uploads/cp1.jpg" alt=""/></a>
                <a href="javascript:;" class="border_b border_l"><img src="uploads/cp2.jpg" alt=""/></a>
                <a href="javascript:;" class="border_l"><img src="uploads/cp3.jpg" alt=""/></a>
            </div>
        </div>
        <div class="productBox m_top10">
            <div class="jd_pTip border_b">
                <h3>京东超市</h3>
            </div>
            <div class="jd_pContent clearfix">
                <a href="javascript:;"><img src="uploads/cp4.jpg" alt=""/></a>
                <a href="javascript:;" class="border_b border_r"><img src="uploads/cp5.jpg" alt=""/></a>
                <a href="javascript:;" class="border_r"><img src="uploads/cp6.jpg" alt=""/></a>
            </div>
        </div>
        <div class="productBox m_top10">
            <div class="jd_pTip border_b">
                <h3>京东超市</h3>
            </div>
            <div class="jd_pContent clearfix">
                <a href="javascript:;"><img src="uploads/cp1.jpg" alt=""/></a>
                <a href="javascript:;" class="border_b border_l"><img src="uploads/cp2.jpg" alt=""/></a>
                <a href="javascript:;" class="border_l"><img src="uploads/cp3.jpg" alt=""/></a>
            </div>
        </div>
    </div>
</div>
<script>
    var banner = $('.jd_banner');
    var bannerWidth = banner.width();
    var bannerHeight = $('.jd_banner').height();
    var search = $('.jd_search');
    $(window).on('scroll', function () {
        var scrollTop = document.documentElement.scrollTop;
        var opacity = scrollTop / bannerHeight;
        search.css('backgroundColor',"rgba(255, 35, 34, "+ opacity +")")
    })
    var imgBox = $('.banner_img');
    var circle = $('ol').find('li');
    var first = imgBox.find('li:eq(0)');
    var last = imgBox.find('li:last');
    first.clone().appendTo(imgBox);
    last.clone().prependTo(imgBox);
    var lis = imgBox.find('li');
    var count = lis.length;
    imgBox.width(count * bannerWidth);
    lis.each(function (index) {
        $(lis[index]).width(bannerWidth)
    })
    imgBox.css('left',-bannerWidth)
    $(window).on('resize',function () {                                                                       bannerWidth = banner.width();
        lis.each(function (index) {
            $(lis[index]).width(bannerWidth);
        })
        imgBox.width(count * bannerWidth);
        imgBox.css('left', -bannerWidth)
    })
    //轮播
    var index =1;
    function animation() {
        imgBox.animate(
                {'left': -index * bannerWidth},
                500,
                'ease-in-out',
                function () {
                    if (index == count - 1) {
                        index = 1;
                        imgBox.css('left', -index * bannerWidth)
                    } else if (index == 0) {
                        index = count - 2;
                        imgBox.css('left', -index * bannerWidth)
                    }
                    circle.removeClass('active').eq(index - 1).addClass('active');
                }
        )
    }
    var timerId;
    function startTime() {
        timerId = setInterval(function () {
            index++;
            animation()
        },2000)
    }
    startTime()
    imgBox.on('swipeLeft', function () {
        clearInterval(timerId)
        index++;
        animation();
        startTime()
    })
    imgBox.on('swipeRight',function () {
        clearInterval(timerId);
        index--;
        animation();
        startTime()
    })
</script>
</body>
</html>